<template>
  <div id="logorder">
    <el-button size="mini" type="text" @click="to">日志</el-button>
    <el-dialog :append-to-body="true" :visible.sync="dialog" :title="'日志'" width="680px">
      <!--表格渲染-->
      <el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
        <el-table-column prop="orderStatus" label="工单状态">
          <template slot-scope="scope">
            <div v-for="item in statusOptions" :key="item.id">
              <el-tag v-show="scope.row.orderStatus.toString() === item.value">{{ item.label }}</el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="operator" label="操作人"/>
        <el-table-column prop="createTime" label="操作时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="content" label="日志内容"/>
      </el-table>
      <!--分页组件-->
      <el-pagination
        :total="total"
        style="margin-top: 8px;"
        layout="total, prev, pager, next, sizes"
        @size-change="sizeChange"
        @current-change="pageChange"/>
    </el-dialog>
  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import initDict from '@/mixins/initDict'
import { parseTime } from '@/utils/index'
import { get } from '@/api/dictDetail'
import { del } from '@/api/tWorkOrderLog'
export default {
  name: "logOrder",
  mixins: [initData],
  props: {
    value: {
      type: Object,
      required: true
    },
    sup_this: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      loading: false, dialog: false,
      statusOptions: []
    }
  },
  created() {
    this.$nextTick(() => {
      this.getDict("order_status")
    })
  },
  methods: {
    parseTime,
    checkPermission,
    beforeInit() {
      this.url = 'api/tWorkOrderLog'
      const sort = 'id,desc'
      this.params = { page: this.page, size: this.size, sort: sort,orderId: this.value.orderCode}
      return true
    },
    async getDict(name) {
      return new Promise((resolve, reject) => {
        get(name).then(res => {
          if(name=='order_status')
            this.statusOptions = res.content
          resolve(res)
        }).catch(err => {
          reject(err)
        })
      })
    },
    to() {
      this.dialog = true
      this.init()
    },
  }
}
</script>

<style scoped>
  #logorder{
    display: inline-block;
    margin-right: 3px;
  }
</style>
